const Koa = require('koa');
const Router = require('koa-router');
var cors = require('koa-cors');
const bodyParser = require('koa-bodyparser');
const jsonData = require("./dist/imgListInfo");

const app = new Koa();
app.use(cors());
const router = new Router();

app.use(async (ctx, next) => {
  ctx.set('Access-Control-Allow-Origin', "*");
  ctx.set('Access-Control-Allow-Headers', 'content-type');
  ctx.set('Access-Control-Allow-Methods', 'OPTIONS,GET,HEAD,PUT,POST,DELETE,PATCH')
  await next();
});
router.get('/get', (context, next) => {
  context.body = jsonData;
})
app.use(bodyParser());
app.use(router.routes()).use(router.allowedMethods());
app.listen(3001, () => {console.log('server listen on 3001')
    console.log(jsonData)
})
